package cn.bdqn.dept.hystirx;

import cn.bdqn.dept.client.DeptFeignClient;
import cn.bdqn.model.pojo.Dept;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 徐凤年
 * @Date 2022/3/25 22:07
 * @Version 1.0
 */
@Component
public class DeptClientFallBackFactory implements FallbackFactory {
    @Override
    public Object create(Throwable cause) {
        return new DeptFeignClient(){
            public Dept getDeptId(int id){
                System.out.println("系统出现问题,稍等1");
                return new Dept(id,"服务降级","");
            }
            public boolean deptAdd(Dept dept){
                System.out.println("系统出现问题,稍等2");
                    return false;
            }
            public List<Dept> getDeptList(){
                System.out.println("系统出现问题,稍等3");
                return new ArrayList<>();
            }
        };
    }
}
